package com.yunji.order.emuns;

import com.yunji.common.utils.bean.BeanUtils;
import lombok.Getter;

import java.util.Objects;

@Getter
public enum OrderCancelTypeEnum {
    SYSTEM(1, "系统自动关闭"),
    MANUAL(2, "人工手动关闭");
    private final Integer code;
    private final String text;

    OrderCancelTypeEnum(Integer code, String text) {
        this.code = code;
        this.text = text;
    }

    public static String get(Integer code) {
        if (BeanUtils.isNull(code)) {
            return null;
        }
        OrderCancelTypeEnum[] enums = OrderCancelTypeEnum.values();
        for (OrderCancelTypeEnum e : enums) {
            if (Objects.equals(e.code, code)) {
                return e.text;
            }
        }
        return null;
    }
}
